<?php 
$ubigeo = '';
$edit = '';
$fecdoc = '';
$fecent = '';

$ocprov = '';
$ocmonto = '';
$ocldoc = '';
$ocref = '';
$orden = '';
$disable2 = '';
$itm_cnt = 0;
$buscar = false;
$find = false;
$combo_alm = '';
$row = '';
include('../Connections/KRAPPERCON.php');
include ("../Connections/Accesos.php");
$orden = '';
$combo = '';
include('../Query_Min/getAlmacenesProc.php');
$combo_alm = $combo;
$combo_um = '';
include('../Query_Min/getUMedidas.php');
//echo str_replace('h','xxx','hola');
//echo $combo;
if (isset($_GET['orden'])) {
$orden = $_GET['orden'];
$buscar = true;
}
if ($buscar){
	$sql_oc = "call sp_findOC(".$orden.");";
	$res = $mysqli->query($sql_oc) or die($mysqli->error.__LINE__);;
	if ($res){
		
		while($row = $res->fetch_assoc()){
			if ($itm_cnt==0){
				$find = true;
				$edit = '';
				$disable2 = "disabled";
			// Obtener Datos de cabecera
				$fecdoc = $row['OrdenFecDoc'];
				$feccre = $row['OrdenFecCre'];
				$userid  = $row['UserID'];
				$fecent = $row['OrdenFecEnt'];
				$ocprov = $row['ProveedID'];
				$ocref = $row['OrdenRef'];
				$ocmonto = $row['OrdenMonto'];
				$ocldoc = $row['ClaDocID'];
				$ocmoneda = $row['MoneyID'];
			}
			$itm_cnt = $itm_cnt + 1;
			$oc_posn[] = $row['OrdenPos'];
			$oc_dcto[] = $row['DetOrdDct'];
			$oc_cods[] = $row['ArticuloID'];
			$oc_noms[] = $row['DetOrdTxt'];
			$oc_prun[] = $row['DetPreUM'];
			$oc_ctdf[] = $row['DetCtdFin'];
			$oc_unm[] = $row['UniMedID'];
			//$oc_brut[] = $row[''];
						
			$oc_spid[] = $row['SolPedID'];
			$oc_spit[] = $row['SolPedItm'];
			$oc_qtpe[] = $row['DetOrdQtp'];
			$oc_qtat[] = $row['DetOrdQta'];
			$oc_nets[] = $row['DetPreNet'];
			$oc_almc[] = $row['AlmacenID'];
			//$oc_cent[] = $row['CentroID'];
			$oc_dels[] = $row['DetOrdDel'];
		}
		$res->close();
		$mysqli->check_result();
	}
}
?>

<div>
<table width="100%" cellpadding="0" cellspacing="0" class="noCss">
<tr>
<td>
  <input type="button" value="Nueva OC" onclick="nuevaOC();" />
  &nbsp;
  <input style="display:<?php echo $edit ?>" type="button" value="Editar" onclick="editarOC();" />
  &nbsp;
  <input type="button" value="Grabar" onClick="grabarOC()">&nbsp;<input type="button" value="Imprimir" onClick="imprimirOC()">&nbsp;<input type="button" value="Listado" onClick="listarOC()">&nbsp;<!--<input type="button" value="Verificar" onClick="verificarOC()">-->
&nbsp;  <input type="text" name="t_mo_noc" id="t_mo_noc" placeholder="Doc.Compras" onkeypress="showOC(event)" /></td>
<td align="right">
<input align="right" onkeypress="if(event.keyCode==13) takeSolPed();" type="text" name="t_sp_ref" id="t_sp_ref" />&nbsp;<input type="button" align="right" value="Tomar SolPed" onclick="takeSolPed()" />
</td>
</tr>
</table>
</div>
<?php 
if ($find){
?>
<div class="subTit">
<?php 
echo "Documento de Compras ".$orden." creado por ".$userid." el ".$feccre;
?>
</div>
<?php
}
?>

  <table width="100%" border="0" cellspacing="0" id="tbl_dat_oc" cellpadding="0">
    <tr>
      <td>Clase de Documento :</td>
      <td>
        <select name="cb_oc_cdoc"  class='<?php echo $disable2; ?>' id="cb_oc_cdoc">
        <?php 
		$cladoc = 'OC';
		include('../Query_Min/getClaDocs.php');
		?>
        </select>
      </td>
      <td>Numero de Orden :</td>
      <td><span style="font-weight:bold" id="sp_nroord"></span></td>
    </tr>
    <tr>
      <td>Fecha Documento :</td>
      <td>
        <input name="t_fecdoc"  type="text" id="t_fecdoc" size="15" maxlength="10" class='tcal clsReq' onchange="changeMdOC();">
      </td>
      <td>Proveedor :</td>
      <td>
        <select name="cb_proveedor" class='<?php echo $disable2; ?>' id="cb_proveedor">
        <?php 			
		include('../Query_Min/getProveedores.php');
		 ?>
        </select>
      </td>
    </tr>
    <tr>
      <td>Fecha Entrega :</td>
      <td>
        <input name="t_fecent" type="text" id="t_fecent" size="15" class="tcal clsReq" maxlength="10">      </td>
      <td>Monto Total(MD) :</td>
      <td><span id="sp_monord" style="font-weight:bold;"></span></td>
    </tr>
    <tr>
      <td>Moneda :</td>
      <td><select name="cb_oc_mon" id="cb_oc_mon" onchange="changeMdOC();">
        <?php include ('../Query_Min/getMonedas.php'); ?>
      </select>
      &nbsp;TC:&nbsp;<span id="sp_tcam">1.00</span> </td>
      <td>Monto (ML) :</td>
      <td><span id="sp_monord_ml" style="font-weight:bold;"></span></td>
    </tr>
    <tr>
      <td>Almacen Destino :</td>
      <td><select onchange="setOC_Alm(this)">
        <?php echo $combo_alm;   ?>
      </select></td>
      <td>Referencia :</td>
      <td>
        <input type="text" name="t_oc_ref" id="t_oc_ref" />      </td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td colspan="4">
      <input name="btn_prv" type="button" id="btn_prv" onclick="showProvOC();" value="Control de Provisiones" <?php if($buscar) echo "next='show'"; ?> />
      <div id="d_prov_oc" <?php if($buscar) echo 'class="noView"'; ?> >
      <table width="100%" id="tbl_prv_oc" border="0" cellspacing="0" cellpadding="0">
      <thead>
        <tr>
          <th scope="col">Clase</th>
          <th scope="col">Monto</th>
          <th scope="col">Moneda</th>
          <th scope="col">Monto Soles</th>
          <th scope="col">&nbsp;</th>
          </tr>
        </thead>
        <tbody>
        <tr class="trLast noView" deleted='0'>
          <td >
            <select class='prv_cc' id="cb_cc" style="width:96%">
            <?php 			
			$cond = '';
			include('../Query_Min/getCondiciones.php');
		 ?>
            </select>          </td>
          <td>
            <input type="text" class="prv_imp qt" onchange="mr(this);" style="width:96%"/>
          </td>
          <td>
            <select class="prv_mon" style="width:90%">
            <?php 			
		include('../Query_Min/getMonedas.php');
		 ?>
            </select>
          </td>
          <td><input type="text" disabled="disabled" class="prv_pen qt disabled" style="width:96%" />          </td>
          <td><input type="button" onclick="delProvOC(this)" value="Quitar" /></td>
          </tr>
        </tbody>
        <tfoot>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
          <td>
            <input type="button" name="btn_add_con" class="enabled" id="btn_add_con" value="Agregar Provisi&oacute;n"/>
          </td>
          <td>&nbsp;</td>
          </tr>
        </tfoot>
      </table>
      </div>
      </td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td colspan="4">
        <div id="d_oc_itm">
    <?php include ('Opers/OperItmOC.php'); ?>
    </div><br />
    <div id="d_oc_his">    </div>      </td>
      </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </table>

<script type="text/javascript">

$("#btn_add_con").click(function(){
	addProvOC();
});

function nuevaOC(){
/*	$('#sp_nroord,#sp_monord').html('');
	GEBI('cb_oc_cdoc').selectedIndex = 0;
	GEBI('cb_proveedor').selectedIndex = 0;		
	$('#tbl_dat_oc input[type|=text]').val('');
	editarOC();
	$('#tbl_itm_oc tbody tr').not(':last').remove();
	addPos();	*/
	loadPage('Procesos/MantOC.php');
}

function updItemOC(){
	var oc = $.trim($("#sp_nroord").html());
	if (oc!=''){
	$('#d_oc_itm').loadx("Procesos/Opers/OperResOC.php",
	{
	oper : 'view',
	orden : oc
	});
	}
}

function grabarOC(){
	if(!$("#tbl_dat_oc").checkInput()){
	return;
	}

	var c_itm = 0;

	var items = "";
	var provision = "";
	var orden = $.trim($('#sp_nroord').html());	
//	if ($.trim(orden)== ""){
	// Grabar OC	
	
	// Obtiene Provisiones de Cabecera
	$("#tbl_prv_oc tbody tr").not(".trLast").each(function(){
		var fila = $(this);
		var cc_cod = fila.find('.prv_cc').val();
		var cc_imp = pFloat(fila.find('.prv_imp').val());
		if (cc_imp==0 || cc_imp == null )
		return;
		var cc_mon = fila.find('.prv_mon').val();
		var cc_pen = pFloat(fila.find('.prv_pen').val());
		var del = fila.attr('deleted');
		//
		provision = provision + cc_cod+"|"+cc_imp+"|"+cc_mon + "|" + del + "#";
	});
	
	// Obtiene Items de la OC
			$('#tbl_itm_oc tbody tr').each(function(){
				var fila = $(this);
				var pos = pInt(fila.attr('title'));
				//var row = fila.find('td:first');		
				var cod = fila.find('.clsCodOc').valx();
				if ($.trim(cod)!="" && cod !=null){
				if (fila.hasClass('deleted'))
				{
					cod = 'DEL';
				}
				var txt = fila.find('.clsTxtOc').html();
				var pru = pFloat(fila.find('.clsCstUni').val());
				var qty1 = pInt(fila.find('.clsQtyOc').val());
				var qty2 = pInt(fila.find('.clsCtdFin').html());	
				var unm = fila.find('.clsQtyUM').val();			
				var dct = pFloat(fila.find('.clsDctOc').val())
				var alm = fila.find('.clsOCAlm').val();
				var sp_id = fila.find('.clsSolpID').html();
				var sp_it = fila.find('.clsSolpIt').html();
				/*
				items = items + pos + '|' + cod + '|' + pru+ '|' + dct + '|' + qty1 + '|' + qty2  +'|' + txt + '|' + unm + '|' + sts + '|' + alm  +"#";
				*/
				items = items + pos + '|' + cod + '|' + pru+ '|' + dct + '|' + qty1 + '|' + qty2  +'|' + txt + '|' + unm + '|'+ sp_id + '|' + sp_it + '|' + '0' + '|' + alm + "#";
				c_itm = c_itm  + 1;
				}
				else {
				if (!fila.hasClass('trLast')){
					fila.remove();
				}
				}
			});
			
			if (c_itm == 0){
				alert('No se han registrado Items en el Documento');
				return;
			}
	///-----------------
		sendData('Procesos/Opers/OperOC.php',
		{
		orden : orden,
		oper : 'upd',
		provision : provision,
		cb_oc_cdoc : GEBI('cb_oc_cdoc').value,
		t_fecent : GEBI('t_fecent').value,
		t_fecdoc : GEBI('t_fecdoc').value,
		cb_proveedor : GEBI('cb_proveedor').value,	
		moneda : GEBI('cb_oc_mon').value,
		t_oc_ref : GEBI('t_oc_ref').value,
		items : items
		});
	
	/*
	else {
	// Actualizar OC
	$('#tbl_itm_oc tbody tr').each(function(){
				var fila = $(this);
				var posn = fila.attr('title');
				var no_send = false;
				if (posn == null || $.trim(posn) == '') {
				posn = 0; //Indica que es posicion nueva
				}
				if (posn < 0){
				no_send = true;
				posnr = Math.abs(posn);
				}
				if (fila.hasClass('deleted')){
				items = items + posn + '|' + 'DEL|0|0|0|_|0#' 
				fila.addClass('rowDel');
				}
				else if (!no_send) {
					var cod = fila.find('.clsCodOc').val();
					if ($.trim(cod)!="" && cod !=null){
						var txt = fila.find('.clsTxtOc').html();
						var pru = fila.find('.clsCstUni').val();
						var qty = fila.find('.clsQtyOc').val();	
						var dct = fila.find('.clsDctOc').val();
						var alm = fila.find('.clsOCAlm').val();
						items = items + posn + '|' + cod + '|' + pru + '|' + dct + '|' + qty + '|' + txt + '|' + alm + "#";
					}
					else {
						if (!fila.hasClass('trLast')){
						fila.remove();
						}
					}
				}				
			});
			// Enviar Info al Servidor
		sendData('Procesos/Opers/OperOC.php',
		{
		oper : 'upd',
		orden : orden ,
		cb_oc_cdoc : GEBI('cb_oc_cdoc').value,
		t_fecent : GEBI('t_fecent').value,
		t_fecdoc : GEBI('t_fecdoc').value,
		cb_proveedor : GEBI('cb_proveedor').value,	
		t_oc_ref : GEBI('t_oc_ref').value,
		items : items
		});
	}
	*/
}

function imprimirOC(){
var oc = $.trim($('#sp_nroord').html());
	if (oc!=''){
		window.open('Prints/printOrden.php?numord='+oc);
	}
	else {
	showError('Debe Cargar un Documento de Compra');
	}
}

function addPosOC(){
var newrow = $('#tbl_itm_oc tbody .trLast').clone().removeClass('trLast').css('display','');;
newrow.find('input[type|=text]').val('');
$('#tbl_itm_oc tbody .trLast').before(newrow);
}

function enterOC_Cod(obj,fn){
//if (e.keyCode == 13){
	if ($.trim(obj.val()) == ''){
	obj.parent().next().find('span').html('');
	return;
	}
	var fila = obj.parent().parent();
	obj.txtLoad();
	sendData('Query_Min/getDatArticulo.php',{t_codart : obj.val() , field : 'venta'},function(){
		 var mobj  = eval('(' + $('#d_result').html() + ')');
		 fila.find('.clsTxtOc').html(mobj.desc);
		 fila.find('.clsCstUni').val("0.00").focus();
		 fila.find('.clsDctOC').val(myRound(mobj.dcto1));
		 obj.val(mobj.code);
		 obj.attr('title',mobj.code);
		 obj.etxtLoad();
		 setTimeout(fn,0);
	});
	//}
}

function listarOC(){
	loadPage('Consultas/LstOrdCom.php');
}

function delPos_OC(obj){
	var fila = $(obj).parent().parent();
		var pos = pInt(fila.attr('title'));
		var rows = $('#tbl_itm_oc tbody tr').length;
	if (rows > 1){
		if (pos == 0){
			fila.remove();
		}
		else {
		fila.hide().addClass('deleted');
		}
		calcOC1();
	}
}

function editarOC(){
	$('#tbl_dat_oc *').enable();
}

function noEditOC(){
	$('#tbl_dat_oc *').not('#btn_prv').disable();
}

function calcOC1(obj){
// recibe cantidad
	var monto = 0;
	var a = $('#tbl_itm_oc tbody tr').each(function(){
		var fila = $(this);
		var tcod = fila.find('.clsCodOc');
		var code = $.trim(tcod.valx());
		
		var fn = function(){
			var ctd = pInt(fila.find('.clsQtyOc').val());
			var pre = pFloat(fila.find('.clsCstUni').val());
			var dct = pFloat(fila.find('.clsDctOC').val());
			var unmqty = pInt(fila.find('.clsQtyUM option:selected').attr('ctd'));
			var new_qty = unmqty * ctd;
			var bruto = myRound(ctd*(pre* (1 - (dct * 0.01)) ));
			fila.find('.clsBruOc').html(bruto);
			var neto = bruto;			
			fila.find('.clsNetOc').html(neto);
			fila.find('.clsCtdFin').html(new_qty);

			var net = 0;
			//var pvp = 0;
			
			var x  = $('#tbl_itm_oc tbody tr').each(function(){			
				var row = $(this);
				if (!row.hasClass('deleted')){
					var cod  = row.find('.clsCodOc').val();
					if ($.trim(cod)!=''){
						net = net + pFloat(row.find('.clsBruOc').html());
					}
				}
			});
			
			var tc = pFloat($("sp_tcam").html());
			
			$('#sp_monord').html(myRound(net));
			$('#sp_monord_ml').html(myRound(net) * tc);
			changeMdOC();
		}
		
		if (code != tcod.attr('title')){
			enterOC_Cod(tcod,fn);
		}
		else {
			setTimeout(fn,0);
		}

	});
			
	
}

function verificarOC(){
	//calcSubt();
}

function setOC_Alm(obj){
$('.clsOCAlm').val(obj.value);
}

function introTr_OC(e){
	if (e.keyCode==13){
	calcOC1();
	}
}

function showOC(e){
	if (e.keyCode == 13){
		loadPage('Procesos/MantOC.php',
		{
		oper : 'view',
		orden : GEBI('t_mo_noc').value
		});
	}
}

function verHistOC(obj){
	var pos = pInt(obj.innerHTML);
	var oc = pInt(GEBI('sp_nroord').innerHTML);
	$('#d_oc_his').loadx('Procesos/Opers/OperResOC.php',{ oper : 'hist' , orden : oc , posic : pos });
}

function showDocOC(obj){
	var doc = obj.innerHTML;
	var tdoc = $(obj).parent().prev().html();
	if (tdoc=='EM' || tdoc == 'AE'){
	loadPopup(
			{
			url : 'Consultas/Opers/queryKardex.php',
			params : 
				{
				t_kx_codart : '',
				cbo_kx_alm : '',
				t_kx_fini : '',
				t_kx_ffin : '',
				cbo_kx_clase : '',
				movimiento : doc
				}
			}
			);
	}
	else if(tdoc =='RF' || tdoc == 'AF'){
	loadPopup(
			{
			url : 'Procesos/MantFactura.php',
			params : 
				{
				factura : doc
				}
			}
			);
	//var doc = GEBI('t_fc_load').value;
//	loadPage('Procesos/MantFactura.php',{ factura : doc});
	}
}

function takeSolPed(){
	var sp = GEBI('t_sp_ref').value;
	
	sendData('Procesos/Opers/OperSP.php',{ oper : 'take' , solped : sp },function(){
		var obj = eval('(' + $("#d_result").html() + ')');
		
		if (true){
			if (obj.length>0){
			// Borra Items en blanco
					$('#tbl_itm_oc tbody tr').not(".trLast").each(function(){
						fila = $(this);
						var cod = $.trim(fila.find('.clsCodOC').val());
						//alert(cod);
						if ( (cod=="" || cod==null) && (!fila.hasClass('trLast')) ){
							fila.remove();
						}
						
					});
					
					for(x in obj){
					var newrow = $("#tbl_itm_oc tbody .trLast").clone().css('display','').removeClass('trLast');;
					//alert(obj[x].code);
					newrow.find('.clsSolpID').html(obj[x].spID);
					newrow.find('.clsSolpIt').html(obj[x].spItm);
					newrow.find('.clsCodOc').val(obj[x].code);					
					newrow.find('.clsOCAlm').val(obj[x].alm);
					newrow.find('.clsTxtOc').html(obj[x].txt);	
					newrow.find('.clsQtyOc').val(obj[x].qty);	 // Aqui mosrrar solo lo pendient
					newrow.find('.clsCstUni').val(obj[x].preun);
					newrow.find('.clsCtdFin').html(obj[x].qty * obj[x].facUM);	
					newrow.find('.clsQtyUM').val(obj[x].unm);
					newrow.find('.clsBruOc').html(obj[x].brut); // Aqui mutiplicar el pendientre por Precio UM					
					$('#tbl_itm_oc tbody .trLast').before(newrow);
					}
					
					calcOC1();
			}					
		}
		
	});	
}

function addProvOC(){
	var new_prv = $('#tbl_prv_oc tbody .trLast').clone().removeClass('noView').removeClass('trLast');
	new_prv.enableInput();
	$("#tbl_prv_oc tbody").append(new_prv);
}


function delProvOC(o){
o = $(o).parent().parent().remove();
}

function showProvOC(){
var btn=$("#btn_prv");
var newnro = $.trim($("#sp_nroord").html());
	if (btn.attr('next') == "show" ){
		//alert(newnro);
		
		if (newnro!=""){
		// Cargar	
		$('#sp_loader').show();
		$.post('Procesos/Opers/OperResOC.php',{oper : 'provision', orden : newnro },
			function(data){			
			$('#sp_loader').hide();
			var info = eval('(' + data + ')');		
			if (info.length==0) {
			alert('No existen provisiones cargadas');
			$("#d_prov_oc").removeClass('noView');
			return;
			}
			$("#tbl_prv_oc tbody tr").not(".trLast").remove();
			var last = $("#tbl_prv_oc tbody .trLast");
			for (x in info){
				var newfila = last.clone().attr('class','');
				newfila.find('.prv_cc').valx(info[x].cod).attr('disabled','disabled');
				newfila.find('.prv_imp').val(info[x].imp);			
				newfila.find('.prv_mon').val(info[x].mon);						
				newfila.find('.prv_pen').val(info[x].pen);						
				if (info[x].del == 1){
				newfila.find('.prv_imp').attr('disabled','disabled');	
				newfila.find('.prv_mon').attr('disabled','disabled');				
				newfila.find('.prv_pen').attr('disabled','disabled');	
				}
				$("#tbl_prv_oc tbody").append(newfila);
				$("#d_prov_oc").removeClass('noView');
			}
			//$("#d_prov_oc").html();
		});
		}
		else {
		$("#d_prov_oc").removeClass('noView');
		}
		btn.attr('next','hide');
	}
	else if (btn.attr('next') != 'show' ) {
	$("#d_prov_oc").addClass('noView');
	btn.attr('next','show');	
	}
}

function getTC_OC(){
	var	fecha  = GEBI('').value;
	var moned = GEBI('').value;
	$.post('QueryMin/getTC.php',{ fecha : fecha, moneda : moned },
	function(txt){
		txt = eval ('(' + txt + ')');
		GEBI('sp_tcam_oc').innerHTML = txt.value;
	}
	);
}

function calcUM_OC(row){
//alert('');
	var fila=$(row).parent().parent();
	cb = fila.find('.clsQtyUM');
	var umqty = pInt(cb.find("option:selected").attr('ctd'));
	var fila=cb.parent().parent();
	var ctd = pInt(fila.find('.clsQtyOc').val());
	var new_qty = ctd * umqty;
	fila.find('.clsCtdFin').html(new_qty);
}

function changeMdOC(){
	var mon = GEBI('cb_oc_mon').value;
	var fecha = GEBI('t_fecdoc').value;
	var monto = pFloat(GEBI('sp_monord').innerHTML);
	var new_mon = 0;
	
	if (monto==0){
	GEBI('sp_monord_ml').value = '0.00';
	//	return;
	}
	
	if(mon != 'PEN'){
		$.post('Query_Min/getMoneyConv.php',
		{ 
		  from : mon ,
		  fecha : fecha,
		  monto : '100'
		},
		function(d){
			var obj = eval("("+d+")");
			if (obj.value == '0' || obj.value == null || $.trim(obj.value) == '')
			{
				showError(fecha+':No existe TC '+mon+'->PEN');
				GEBI('cb_oc_mon').value = 'PEN';
				new_mon = '0.00';
				GEBI('sp_tcam').innerHTML = '1.00';
			}
			else {
			new_mon = mr4(obj.tc) * pFloat(monto);
			GEBI('sp_tcam').innerHTML = mr4(obj.tc);
			GEBI('sp_monord_ml').innerHTML = myRound(new_mon);
			}
		});
		
	}
	else {
		GEBI('sp_monord_ml').innerHTML = myRound(monto);
	}
	
	
}

<?php
if ($buscar){
	if ($find){
	?>
	$('#sp_nroord').html('<?php echo $orden; ?>');
	GEBI('cb_oc_cdoc').value=('<?php echo $ocldoc; ?>');
	GEBI('t_fecdoc').value=('<?php echo $fecdoc ?>');
	GEBI('t_fecent').value=('<?php echo $fecent; ?>');
	$('#sp_monord').html('<?php echo $ocmonto; ?>');
	GEBI('cb_proveedor').value=('<?php echo $ocprov; ?>');
	GEBI('t_oc_ref').value = '<?php echo $ocref; ?>';
	GEBI('cb_oc_mon').value = '<?php echo $ocmoneda; ?>';
	//$('#tbl_itm_oc tbody').html();
	noEditOC();
	<?php 
	}
	else {
	?>
	showOk('Documento de Compra <?php echo $orden ?> no existe');
	<?php 
	}
}
else {
?>
GEBI('t_fecdoc').value = '<?php echo $hoy; ?>';
GEBI('t_fecent').value = '<?php echo $hoy; ?>';
<?php 
}
?>
</script>